package com.lzb.browser.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.blankj.utilcode.util.ToastUtils;
import com.lzb.browser.BaseAc;
import com.lzb.browser.Content;
import com.lzb.browser.HomeActivity;
import com.lzb.browser.R;
import com.lzb.browser.basic.utils.SPUtil;
import com.lzb.browser.databinding.ActivityInputBackupPswBinding;

public class InputBackupPswActivity extends BaseAc<ActivityInputBackupPswBinding> implements View.OnClickListener {


    @Override
    protected int onCreate() {
        return R.layout.activity_input_backup_psw;
    }

    @Override
    protected void initView() {
        mDataBinding.ivInputBackupPswBack.setOnClickListener(view -> getOnBackPressedDispatcher().onBackPressed());

        mDataBinding.tvConfirm.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.tvConfirm) {//确定
            String input = mDataBinding.etPassword.getText().toString();
            if (TextUtils.isEmpty(input)) {
                ToastUtils.showShort(getString(R.string.please_input_backup_password));
                return;
            }
            String password = SPUtil.getString(mContext, Content.myBackupPassword, "");
            if (input.equals(password)) {
                startActivity(HomeActivity.class);
                finish();
            } else {
                ToastUtils.showShort(getString(R.string.password_error));
            }
        }
    }

    @Override
    protected void initData() {

    }
}